package cn.wizzer.app.user.modules.models;

import cn.wizzer.framework.base.model.BaseModel;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;

import java.io.Serializable;
import java.math.BigDecimal;

@Data
@Table("user_restriction")
public class UserRestriction extends BaseModel implements Serializable {

    @Column("ID")
    @Name
    @Comment
    @ColDefine(type = ColType.VARCHAR, width = 32)
    @PrevInsert(uu32 = true)
    private String id;

    @Column("user_id")
    @Comment
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String userId;

    //region 用户消费限制
    @Column("time_min_restriction")
    @Comment
    @ColDefine(type = ColType.FLOAT, width = 16, precision = 6)
    @Default("10")
    private BigDecimal timeMinRestriction;

    @Column("time_max_restriction")
    @Comment
    @ColDefine(type = ColType.FLOAT, width = 16, precision = 6)
    @Default("1000")
    private BigDecimal timeMaxRestriction;


    @Column("day_restriction")
    @Comment
    @ColDefine(type = ColType.FLOAT, width = 16, precision = 6)
    @Default("10000")
    private BigDecimal dayRestriction;

    @Column("total_restriction")
    @Comment
    @ColDefine(type = ColType.FLOAT, width = 16, precision = 6)
    @Default("200000")
    private BigDecimal totalRestriction;
    //endregion

    //region 代理可设置下级用户的返水字段
    @Column("self_rate")
    @Comment("用户自身返水比单位;万")
    @ColDefine(type = ColType.INT, width = 2)
    @Default("15")
    private int selfRate;

    @Column("super_rate")
    @Comment("此用户所属代理返水比单位;万")
    @ColDefine(type = ColType.INT, width = 2)
    @Default("35")
    private int superRate;

    @Column("gift_rate")
    @Comment("礼物分成;百")
    @Default("50")
    @ColDefine(type = ColType.INT, width = 3)
    private int giftRate;

    @Column("view_rate")
    @Comment("观点分成;百")
    @Default("0")
    @ColDefine(type = ColType.INT, width = 3)
    private int viewRate;
    ///endregion

    @Column
    @Comment("禁用")
    @ColDefine(type = ColType.BOOLEAN)
    @Default("0")
    private Boolean disabled;

    public BigDecimal getBigDecimalSelfRate() {
        return new BigDecimal(selfRate);
    }

    public void setBigDecimalSelfRate(BigDecimal selfRate) {
        this.selfRate = selfRate.intValue();
    }

    public BigDecimal getBigDecimalSuperRate() {
        return new BigDecimal(superRate);
    }

    public void setBigDecimalSuperRate(BigDecimal superRate) {
        this.superRate = superRate.intValue();
    }

}
